import request from 'utils/request';

/**
 * 获取文章列表数据
 * @returns
 */
export const getArticle = (params) => {
	return request({
		url: '/mp/articles',
		method: 'get',
		params
	});
};

/**
 * 删除文章
 * @returns
 */
export const delArticle = (id) => {
	return request.delete(`/mp/articles/${id}`);
};

export const addArticle = (data, draft = false) => {
	return request({
		url: `/mp/articles?draft=${draft}`,
		method: 'post',
		data
	});
};

export const getArticleById = (id) => {
  return request.get(`/mp/articles/${id}`);
}


export const editArticleById = (data,draft) => {
  return request({
    url: `/mp/articles/${data.id}?draft=${draft}`,
    method: 'PUT',
    data
	});
}